| Conditions | 1 |
| Paths | 1 |
| Total Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | const TYPE_ERROR = 'handleActions: Action Types should be not be undefined'; |
||
| 4 | export const handleActions = (map, initialState) => { |
||
|
|
|||
| 5 | Object.keys(map).forEach(key => { |
||
| 6 | if (key === 'undefined') { |
||
| 7 | throw new Error(TYPE_ERROR); |
||
| 8 | } |
||
| 9 | }); |
||
| 10 | |||
| 11 | return (state = initialState, action) => { |
||
| 12 | if (!action) { |
||
| 13 | throw new Error(ACTION_ERROR); |
||
| 14 | } |
||
| 15 | |||
| 16 | if (action.type === undefined) { |
||
| 17 | throw new Error(TYPE_ERROR); |
||
| 18 | } |
||
| 19 | |||
| 20 | const reducerSubFunction = map[action.type]; |
||
| 21 | |||
| 22 | if (typeof reducerSubFunction === 'function') { |
||
| 23 | return reducerSubFunction(state, action); |
||
| 24 | } |
||
| 25 | |||
| 26 | return state; |
||
| 27 | }; |
||
| 28 | }; |
||
| 29 | |||
| 31 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.